jQuery(document).ready(function() {

	var leftMenu = jQuery('body').find('div.mainLeft');
	var mainCate = leftMenu.find('div[id=main_cate_title]');
	var isOpenFirstNews = mainCate.attr('open_news');
	if (isOpenFirstNews == 1) {
		var id = jQuery('#main_content').find('a').attr('id');
        showNewsContent(id);
	} else {
		var newsList = jQuery('#main_content').find('a');
		if (newsList.size() <= 0) {
			mainCate.html(mainCate.find('a').text());
			jQuery('body').find('div.mainLeft').find('div.Lneirong').find('a').click();
		}
	}
	//var el = jQuery('body').find('div.mainLeft').find('div.Lneirong').find('a').first();
	//el.click();
});

function showNewsContent(id, el) {
	if (!id) {
		return false;
	}

	if (!el) {
		el = 'main_content';
	}
	jQuery.ajax({
		url: 'news.php?act=ajax_news_content&requestid=' + Math.random(10000),
		dataType: 'json',
		data: {
			'newsid': id
		},
		success: function(result) {
			jQuery('#sub_title').html('>>' + result.news_title);
			jQuery('#' + el).html(result.news_content);
		}
	});

	return true;
}

function showNewsOfCat(id, el) {
	if (!id) {
		return false;
	}
	if (!el) {
		el = 'main_content';
	}
	jQuery.ajax({
		url: 'news.php?act=ajax_cate_list&requestid=' + Math.random(10000),
		dataType: 'json',
		data: {
			'catid': id
		},
		success: function(result) {
			var currentCate = result.current_cate;
			jQuery('#sub_title').html('>>' + currentCate.cate_title);
			var list = result.list;
			var html = '<table width="98%" height="31" border="0" cellpadding="0" cellspacing="0">';
			var artDate;
			for (var i = 0; i < list.length; i++) {
				html += '<tr><td width="3%" height="26" align="center"><img src="images/jiantou.jpg" /></td>';
				html += '<td width="83%" align="left">';
				html += '<a style="font-size:14px; ling-height:28px;" href="news.php?act=news_content&newsid=' + list[i].news_id + '" target="_blank">' + list[i].news_title + '</a>';
				html += '</td>';
				artDate = list[i].update_date;
				if (!artDate || artDate == 'null') artDate = list[i].create_date;
				html += '<td width="14%" align="left" style="font-size:14px;">' + artDate + '</td>';
				html += '</tr>';
			}
			html += '</table>';
			jQuery('#' + el).html(html);
			delete artDate;
			delete currentCate;
			delete list;
			delete html;
		}
	});
	return true;
}

